#include <cstdio>
#include <vector>

const int N = 3e5 + 5;
int n, m, a[N], ans[N];
bool vis[N];
std::vector<int> vec[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("A.in", "r", stdin);
  freopen("A.out", "w", stdout);
#endif
#endif

  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == -1) ++n;
  }
  for (int i = 1; i <= n; ++i) { vec[i].reserve(m / n * 100); }
  for (int i = 1, tar = 1; i <= m; tar = tar % n + 1) {
    if (!vis[tar]) {
      vec[tar].push_back(a[i]);
      if (a[i] == -1) vis[tar] = true;
      ++i;
    }
  }
  printf("%d\n", n);
  for (int i = 1; i <= n; ++i) {
    printf("%d ", (int)vec[i].size() - 1);
    for (std::vector<int>::iterator iter = vec[i].begin(),
                                    end = vec[i].end() - 1;
         iter != end; ++iter) {
      printf("%d ", *iter);
    }
    putchar('\n');
  }
  return 0;
}